package problem1863;

//1863.找出所有的子集的异或总和再求和
//https://leetcode.cn/problems/sum-of-all-subset-xor-totals/

class Solution {
    int sum = 0, tmp = 0;
    public int subsetXORSum(int[] nums) {
        dfs(nums, 0);
        return sum;
    }
    public void dfs(int[] nums, int u) {
        if(u == nums.length) {
            sum += tmp;
            return;
        }

        //选
        tmp ^= nums[u];
        dfs(nums, u+1);
        tmp ^= nums[u];

        //不选
        dfs(nums, u+1);
    }
}